//保留小数点后n位
export const keepDecimal = (num, n) => {
    var result = parseFloat(num);
    if (isNaN(result)) return false;
    if (isNaN(n)) return false;
    if (n == 0) return result;
    var tens = Math.pow(10,n);
    result = Math.round(num * tens) / tens;
    var s = result.toString();
    var rs = s.indexOf('.');
    if (rs < 0) {
        rs = s.length;
        s += '.';
    }
    while (s.length <= (rs + n)) s += '0';
    return s;
};